package guodaowang.other

import java.util.Properties

import org.apache.spark.sql.{DataFrame, SparkSession}

object Collect {
  def main(args: Array[String]): Unit = {
    val session = SparkSession.builder().appName(this.getClass.getSimpleName).master("local[*]").getOrCreate()
    val properties = new Properties()
    properties.put("user","user01")
    properties.put("password","1q2w3e!@#")
    val url = "jdbc:mysql://rm-2ze3575842g7av270ro.mysql.rds.aliyuncs.com:3306/guodaowang"
    val stationDatas = session.read.jdbc(url,"test_station",properties)
    val xy = session.read.jdbc(url,"qgfsz",properties)
    xy.createTempView("xy")
    stationDatas.createTempView("station")
    val resultdatas: DataFrame = session.sql("select * from station,xy where station.toll_station_name like CONCAT('%',xy.fsmc,'%') ")
    resultdatas.show()
    resultdatas.write.jdbc(url,"tb_toll_station_closing_1",properties)
    print("success")
    session.close()



  }

}
